package common;

import org.jfree.chart.ui.Drawable;

import java.awt.*;
import java.awt.geom.Ellipse2D;
import java.awt.geom.Line2D;
import java.awt.geom.Rectangle2D;

public class CircleDrawer implements Drawable {
    private Paint outlinePaint;
    private Stroke outlineStroke;
    private Paint fillPaint;

    public CircleDrawer(Paint paint, Stroke stroke, Paint paint1) {
        outlinePaint = paint;
        outlineStroke = stroke;
        fillPaint = paint1;
    }

    @Override
    public void draw(Graphics2D graphics2D, Rectangle2D rectangle2D) {
        Ellipse2D.Double double1 = new Ellipse2D.Double(rectangle2D.getX(), rectangle2D.getY(),
                rectangle2D.getWidth(), rectangle2D.getHeight());
        if (fillPaint != null) {
            graphics2D.setPaint(fillPaint);
            graphics2D.fill(double1);
        }
        if (outlinePaint != null && outlineStroke != null) {
            graphics2D.setPaint(outlinePaint);
            graphics2D.setStroke(outlineStroke);
            graphics2D.draw(double1);
        }
        graphics2D.setPaint(Color.black);
        graphics2D.setStroke(new BasicStroke(1.0F));
        Line2D.Double double2 = new Line2D.Double(rectangle2D.getCenterX(), rectangle2D.getMinY(),
                rectangle2D.getCenterX(), rectangle2D.getMaxY());
        Line2D.Double double3 = new Line2D.Double(rectangle2D.getMinX(), rectangle2D.getCenterY(),
                rectangle2D.getMaxX(), rectangle2D.getCenterY());
        graphics2D.draw(double2);
        graphics2D.draw(double3);
    }
}
